# Importing Data
UK <- read_excel("C:/users/Biniam/Desktop/Documents/Academic/Thesis/Analysis Folder/Excel Files/Steel/TSA.xlsx",sheet = "Sheet1", range = "AM1:AM239")

# Checking the Imported Data
View(UK)
# Creating Time Series Data
UK_ts <- ts(UK, start=c(2000,1), end=c(2019,09), frequency=12)
# Viewing and Checking the Created Time Series Data
UK_ts
sum(is.na(UK_ts))
library(forecast)
UK_ts <- tsclean(UK_ts)
UK_ts

# Identification: Plotting the Time Series Data
plot(UK_ts)

# Estimating the appropriate model
UK_ts_model <- auto.arima(UK_ts)
UK_ts_model

# Forecasting
options(max.print=1000000)
UK_ts_forecast <- forecast (UK_ts_model, level=c(95), h=255)
plot(UK_ts_forecast)
UK_ts_forecast             

# Exporting
write.table(UK_ts_forecast, file="/users/Biniam/Desktop/Documents/Academic/Thesis/Result Folder/TSA Results/Excel Files/From R/Steel/UK_TSA.csv", sep=",")
